﻿using ChurchDiary.BLL;
using ChurchDiary.Common;
using ChurchDiary.TableEntity;
using ChurchWebsite.Controllers;
using iTextSharp.text;
using iTextSharp.text.pdf;
using Rotativa;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ChurchWebsite.Areas.Admin.Controllers
{
    public class ChurchController : BaseController
    {
        #region Church
        public ActionResult Index()
        {
            return View();
        }
        public JsonResult GetChurchWithOutPaginationAll()
        {
            return Json(new BLL_Church().GetChurch(),JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetChurchOne(Guid dataId)
        {
            return Json(new BLL_Church().GetChurch(dataId), JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetChurchWithPagination(int PageNo, string SearchKey, string Sort, string SortMode, int PerPage, Guid PartitionId, Guid DesignationId)
        {
            return Json(new BLL_Church().GetChurch(PageNo, SearchKey, Sort, SortMode, PerPage, PartitionId, DesignationId), JsonRequestBehavior.AllowGet);
        }
        public JsonResult SaveChurchDetails(EntityChurch Church)
        {
            BLL_Church BLL = new BLL_Church();
            return Json(new BLL_Church().InsertChurchDetails(Church));
        }
        public JsonResult UpdateChurchDetails(EntityChurch Church)
        {
            BLL_Church BLL = new BLL_Church();
            return Json(new BLL_Church().UpdateChurchDetails(Church));
        }
        public JsonResult DeleteChurch(Guid DataId)
        {
            return Json(new BLL_Church().DeleteChurch(DataId), JsonRequestBehavior.AllowGet);
        }
        #endregion Church
        #region Print
        
        #endregion
        #region ChurchInfo
        /// <summary>
        /// Shows overall summary of that Church
        /// </summary>
        /// <param name="ChurchId">Church Id</param>
        /// <returns>Page Which show the overview of the Church</returns>
        #region Church Information
        public ActionResult ChurchInfo(Guid ChurchId)
        {
            return View();
        }
        #endregion Church Information
        #endregion ChurchInfor
        #region PrintChurch Details
        /// <summary>
        /// Print Church Details
        /// </summary>
        /// <param name="PageNo">Page</param>
        /// <param name="SearchKey"></param>
        /// <param name="Sort"></param>
        /// <param name="SortMode"></param>
        /// <param name="PerPage"></param>
        /// <param name="PartitionId"></param>
        /// <param name="DesignationId"></param>
        /// <returns></returns>
        public ActionResult PrintChurches(string SearchKey, string Sort, string SortMode, Guid PartitionId, Guid DesignationId)
        {
            return new Rotativa.ViewAsPdf(new BLL_Church().PrintChurch(SearchKey, Sort, SortMode, PartitionId, DesignationId));
        }
        #endregion

    }
}
